package com.ming.test.page;

//学生类
public class Student {
//    属性
    String name;//null
    int age;//0
//无参构造
    public Student() {
    }

//    有参构造
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    //    方法
    public  void study(){
        System.out.println("学生在学习！");
    }

    public static void main(String[] ages){
        Student student = new Student();//不显式命名无参构造，这里不报错
        Student student1 = new Student("小红",17);//跑的是有参构造方法
        student.name = "小明";
        student.age = 18;

//        以上两个new实现了方法的重载

        System.out.println(student1.name);//小红
        System.out.println(student1.age);//17

        System.out.println(student.name);//小明
        System.out.println(student.age);//18
        student.study();
    }
}